﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadProps.Definition
{
    public class CreateMetadataFromAttributes : IMetadataBuilder
    {
        public void OnBuilding(MetadataBuildArgs args)
        {
            foreach (var att in args.PropId.DeclaringType.GetCustomAttributes(true)
                .OfType<BaseAttribute>())
            {
                args.SetMetadata(att.Key, att.Value);
            }

            foreach (var att in args.ClrMember.GetCustomAttributes(false)
                .OfType<BaseAttribute>())
            {
                args.SetMetadata(att.Key, att.Value);
            }
        }
    }
}
